#include <iostream>

using namespace std;

int maze[7][7] = {  { 2, 2, 2, 2, 2, 2, 2 },
										{ 2, 0, 0, 0, 0, 0, 2 },
										{ 2, 0, 2, 0, 2, 0, 2 },
										{ 2, 0, 0, 2, 0, 2, 2 },
										{ 2, 2, 0, 2, 0, 2, 2 },
										{ 2, 0, 0, 0, 0, 0, 2 },
										{ 2, 2, 2, 2, 2, 2, 2 } };

int In_i = 1, In_j = 1;
int Out_i = 5, Out_j = 5;
bool found = false;

bool visit(int i, int j)
{
	maze[i][j] = 1;
	
	if (i == Out_i && j == Out_j)
		found = true;
	
	if (!found && maze[i + 1][j] == 0)
		visit(i + 1, j);
	if (!found && maze[i][j + 1] == 0)
		visit(i, j + 1);
	if (!found && maze[i - 1][j] == 0)
		visit(i - 1, j);
	if (!found && maze[i][j - 1] == 0)
		visit(i, j - 1);

	if (!found)
		maze[i][j] = 0;
	return found;
}

int main()
{
	cout << "显示迷宫：\n";
	for (int i = 0; i < 7; i++) {
		for (int j = 0; j < 7; j++)	{
			if (maze[i][j] == 2)
				cout << "██";
			else
				cout << "  ";
		}
		cout << endl;
	}

	if (visit(In_i, In_j)) {
		cout << "\n找到路劲为：\n";
		for (int i = 0; i < 7; i++) {
			for (int j = 0; j < 7; j++)	{
				if (maze[i][j] == 1)
					cout << "☆ ";
				else if (maze[i][j] == 2)
					cout << "██";
				else
					cout << "  ";
			}
			cout << endl;
		}
	}
	else {
		cout << "找不到出口！\n";
	}
	
	return 0;
}